package io.github.talelin.latticy.repository;

import io.github.talelin.latticy.entity.SendCollect;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface SendCollectRepository extends JpaRepository<SendCollect, Long> {

    @Query("select sc \n" +
            "from SendCollect sc \n" +
            "where \n" +
            "sc.mobile = :mobile \n" +
            "and \n" +
            "sc.collectUserId = 0 ")
    List<SendCollect> findIdByMobileAndCollectUserId(String mobile);

    Page<SendCollect> findBySendUserIdOrderByCreateTimeDesc(Long userId, Pageable pageable);

    Page<SendCollect> findByCollectUserIdAndDeleteTimeIsNullOrderByCreateTimeDesc(Long userId, Pageable pageable);

    SendCollect findFirstByCollectUserIdAndStatusAndDeleteTimeIsNullOrderByCreateTimeDesc(Long userId, int Status);
}
